const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
  },
  getScancode: function () {
    var _this = this;
    wx.scanCode({
      success: (res) => {
        var result = res.result;
        console.log(result)
        _this.setData({
          result: result,
        })
        wx.navigateTo({
          url: '../showUsageStatus/showUsageStatus?wireCode=' + result,
        })
      },
      fail: (err) => {
        wx.switchTab({
          url: '../features/features',
        })
      }
    })
    wx.switchTab({
      url: '../features/features',
    })
  },

  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.switchTab({
      url: '../features/features',
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {   
    this.getScancode()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    wx.switchTab({
      url: '../features/features',
    })
  }
})